﻿//--------------------------------------------------------------------------------------------------------------------- 
// <copyright file="BreakRoleInheritance.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights reserved.
// </copyright>
// <summary>
//   Creates a User.
// </summary>
//---------------------------------------------------------------------------------------------------------------------
namespace Collaboris.Saf.Actions.Wss.Security
{
    using System;
    using System.Collections.Generic;

    using Engine;
    using Entities;
    using Microsoft.SharePoint;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    using Utils;

    [CollaborisClass(
        Title = "Break Role Inheritance",
        ReleaseStatus = ReleaseStatus.Beta,
        DisableDocumentation = true,
        ContactAuthorEmail = "Support@Collaboris.co.uk",
        Summary = "Summarise the Action so much that the Administrator can easily understand " +
                  "what it's actually doing. You may also want to supply a link " +
                  "to any Urls that are relevant, or also any other actions.",
        Remarks = "PUT A GENERAL REMARKS AND ALSO INFO ABOUT WHAT THE UNDO ACTUALLY DOES.",
          ClassGuid = "{156E17A5-A7BA-4e1f-8A48-1BC341A7C656}"
    )
    ]
    public class BreakRoleInheritance : WSSActionBase<SecurableObjectInfo>
    {

        private bool userIsDirty;

        /// <summary>
        /// Does the action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        protected override ProcessStatus DoAction(SafContext context, SecurableObjectInfo entity)
        {
        
            return ProcessStatus.Success;
        }

        /// <summary>
        /// Undoes the action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        protected override ProcessStatus UndoAction(SafContext context, SecurableObjectInfo entity)
        {
           

            return ProcessStatus.Success;
        }


        /// <summary>
        /// Checks the Data entity used by the Action for Validity
        /// </summary>
        /// <param name="context">The <see cref="SafContext"/> passed in by the SAF Engine.</param>
        /// <param name="entity">The data entity to Validate.</param>
        /// <param name="errors">List of <see cref="ValidationError"/>s</param>
        /// <param name="mode"><see cref="ProcessMode"/>signalling wheter we are Doing, or Undoing the action.</param>
        /// <returns>false if invalid; otherwise true.</returns>
        protected override bool IsValid(SafContext context, SecurableObjectInfo entity, ref List<ValidationError> errors, ProcessMode mode)
        {
            
            int currentCount = errors.Count;

            // Validate each object now.    
          

            // Have we added errors ?
            return errors.Count == currentCount;
        }

        
    }

    public class SecurableObjectInfo : WSSEntityBase
    {
    }
}
